package com.mtw.bbs.common.core.exception;

import com.mtw.bbs.common.core.enums.ResultCode;
import lombok.Getter;

@Getter
public class BaseException extends RuntimeException {
    /**
     * 异常对应的错误类型
     */
    private String errorCode;

    /**
     * 默认是系统异常
     */
    public BaseException() {
        this.errorCode = ResultCode.SERVICE_EXP.getCode();
    }

    public BaseException(String message) {
        super(message);
        this.errorCode = ResultCode.SERVICE_EXP.getCode();
    }

    public BaseException(String errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public BaseException(String message, Throwable cause) {
        this(ResultCode.SERVICE_EXP.getCode(),message, cause);
    }

    public BaseException(String errorCode, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }

    public String getCode(){
        return this.errorCode;
    }
}
